<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1 id="h1"></h1>
  <script>
    // 当页面刷新后内容不丢失
    // 1、cookie
    const h1 = document.querySelector('#h1')
    // 存
    document.cookie = 'name=lisi'
    document.cookie = 'sex=hh'
    // 取
    h1.innerHTML = document.cookie

    // 2、localStorage --- 长期存在
    // localStorage.setItem('user', 'zhaosi')
    console.log(localStorage.getItem('user'));


    // 3、sessionStorage --- 浏览器窗口关闭就消失了
    // sessionStorage.setItem('user', 'zhaosi')
    console.log(sessionStorage.getItem('user'));
  </script>
</body>

</html>